package com.tbb.app.base.vo;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tbb.app.base.entity.Note;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.util.Date;
import java.util.List;

@Data
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(description = "笔记详情VO")
public class NoteAdminDetailVO {
    @ApiModelProperty("笔记id")
    private String id;

    @ApiModelProperty("频道id")
    private String channelId;

    @ApiModelProperty("频道名称")
    private String channelName;

    @ApiModelProperty("标题")
    private String title;

    @ApiModelProperty("作者账号")
    private String userAccount;

    @ApiModelProperty("作者昵称")
    private String userName;

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @ApiModelProperty("修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    @ApiModelProperty("正文")
    private String text;

    @ApiModelProperty("图片urls")
    private List<String> imgs;

    public NoteAdminDetailVO(Note n) {
        this.id = n.getId();
        this.channelId = n.getChannelId();
        this.createTime = n.getCreateTime();
        this.updateTime = n.getUpdateTime();
        this.title = n.getTitle();
        this.text = n.getText();
        this.imgs = JSON.parseArray(n.getImgs(), String.class);
    }
}
